<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class OAuthController extends Controller
{
    public function oauth(Request $request)
    {
//        dd($request->code);
        $http = new \GuzzleHttp\Client;
        $response = $http->post('http://localhost:8000/oauth/token', [
            'form_params' => [
                'grant_type' => 'authorization_code',
                'client_id' => '12',
//                'client_secret' => 'dqNg2Y3X9veOAttCZa7JGGWWIqupFzIBBzjNKf7o',
                'client_secret' => 'dqNg2Y3X9veOAttCZa7JGGWWIqupFzIBBzjNKf7o',
                'redirect_uri' => 'http://localhost:8081/callback',
                'code' => $request->get('code'),
            ]
        ]);
        return json_encode((string) $response->getBody(), true);
    }
}
